<?php
namespace Home\Model;
use Think\Model;
use Think\Db\Driver\Sqlsrv;
class ComBzxxModel extends Model {
	public $_table_name='com_bzxx';
	public $_pk='bzxxid';

	public function getRow($where='',$order=''){

		if(empty($order)) $order=$this->_pk.' asc';
		$sql="select top 1 * from ".$this->_table_name;
		if(!empty($where)) $sql.=" where ".$where;
		$sql.=" order by ".$order;

		$rows = $this->query($sql);

		return $rows[0];
	}
	
	public function getAllRows($where='',$order='',$use_cache=false)
	{
		if(empty($order)) $order=$this->_pk.' asc';
		$sql="select * from ".$this->_table_name;
		if(!empty($where)) $sql.=" where ".$where;
		$sql.=" order by ".$order;
		//echo $sql;
		$rows = $this->query($sql);
		return $rows;

	}

	public function getMxRows($ssbzid)
	{
		$sql="select * from com_bzxx_mx where ssbzid=".$ssbzid." order by bzmxid asc";
		$rows = $this->query($sql);
		return $rows;
	}


	public function get_xm()
	{
		$sql="select * from syszx order by zxid asc";
		$rows = $this->query($sql);
		$xms=array();
		foreach($rows as $row)
		{
			$xms[$row['zxid']]=$row['zxname'];
		}
		return $xms;
	}

	public function get_xmms($xmid,$ssnd)
	{
		$sql="select * from sysbzxm where sszx=".$xmid." and ssnd=".$ssnd."  order by bzxmid asc";

		$rows = $this->query($sql);
		$xms=array();
		foreach($rows as $row)
		{
			$xms[$row['bzxmid']]=$row['bzname'];
		}
		return $xms;
	}

}